#ifndef _MYDB_H
#define _MYDB_H
#ifdef __cplusplus
extern "C" {
#endif
#include "mydata/model.h"
// parameters to return.
#define RETV

/** mydata **/
int mydata_init(const char *realname);
int mydata_sample(const char *name);

/** Session **/
// insert, update, remove
int mydata_insert_session(Session *session);
int mydata_remove_session(const char *uuid);
// verify
int mydata_session_exist(const char *uuid, uint32_t *user_id);
int mydata_session_user_exist(uint32_t user_id, char **uuid);
// get
// other

/** User **/
// insert, update, remove
int mydata_insert_user(User *user);
int mydata_update_user(User *user, uint32_t field);
int mydata_remove_user(uint32_t user_id);
// verify
int mydata_user_mail_exist(const char *mail, uint32_t *user_id);
int mydata_mail_passwd_match(const char *mail, const char *passwd, uint32_t *user_id);
int mydata_id_passwd_match(uint32_t user_id, const char *passwd);
// get
int mydata_get_user_by_id(uint32_t user_id, User **user);
int mydata_get_user_by_mail(const char *mail, User **user);
int mydata_get_user_list(ArrayTable *result);

/** Note **/
// insert, update, remove
int mydata_insert_note(Note *note);
int mydata_update_note(Note *note, uint32_t field);
int mydata_remove_note(uint64_t note_id);
// verify
int mydata_own_note(uint32_t user_id, uint64_t note_id);
int mydata_note_is_public(uint64_t note_id);
int mydata_note_is_shared(uint64_t note_id, uint32_t user_id);
// get
int mydata_get_note_by_id(uint64_t note_id, Note **note);
int mydata_get_note_by_uuid(const char *uuid, Note **note);
int mydata_get_all_public_note_number(uint64_t *number);
int mydata_get_all_public_note_list(uint64_t start, uint32_t count, ArrayTable *result);
int mydata_get_my_note_number(uint32_t user_id, uint64_t *number);
int mydata_get_my_note_list(uint32_t user_id, uint64_t start, uint32_t count, ArrayTable *result);

/** Tag **/
// insert, update, remove
int mydata_insert_tag(Tag *tag);
int mydata_remove_tag(uint64_t note_id, const char *tag);
int mydata_remove_tags(uint64_t note_id);
// verify
int mydata_tag_exist(uint64_t note_id, const char *tag);
// get
int mydata_get_tags(uint64_t note_id, ArrayTable *result);
int mydata_get_tag_list(uint32_t user_id, ArrayTable *result);

/*
int mydata_get_my_note_number(uint32_t my_id, uint32_t *number);
int mydata_get_my_note_list(uint32_t my_id, uint32_t start, uint32_t count, uint32_t field, NoteArray *result);

int mydata_get_user_shared_note_number(uint32_t my_id, uint32_t user_id, uint32_t *number);
int mydata_get_user_shared_note_list(uint32_t my_id, uint32_t user_id, uint32_t start, uint32_t count, uint32_t field, NoteArray *result);

int mydata_get_all_shared_note_number(uint32_t my_id, uint64_t *number);
int mydata_get_all_shared_note_list(uint32_t my_id, uint64_t start, uint32_t count, uint32_t field, NoteArray *result);

int mydata_get_user_public_note_number(uint32_t user_id, uint32_t *number);
int mydata_get_user_public_note_list(uint32_t user_id, uint32_t start, uint32_t count, uint32_t field, NoteArray *result);

int mydata_get_all_public_note_number(uint64_t *number);
int mydata_get_all_public_note_list(uint64_t start, uint32_t count, uint32_t field, NoteArray *result);


// Tags.
int ns__get_note_tag_list(uint32_t my_id, uint64_t note_id, TagArray *result);
int ns__get_all_my_tag_list(uint32_t my_id, NoteArray *result);
int ns__add_my_note_tag(uint32_t my_id, uint64_t note_id, char *tag, int *status);
int ns__remove_my_note_tag(uint32_t my_id, uint64_t note_id, char *tag, int *status);
int ns__get_my_tag_note_list(uint32_t, char *tag, uint32_t field, NoteArray *result);
*/
// Share.
//

/*

int mydata_get_user_number(uint32_t my_id, uint32_t *number);
int mydata_get_user_list(uint32_t my_id, uint32_t start, uint32_t count, uint32_t field, UserArray *result);

int mydata_get_note_by_uuid(uint32_t my_id, char *uuid, uint32_t field, Note **note);
*/
#ifdef __cplusplus
}
#endif

#endif /* _MYDB_H */

